Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a*comparative BOX-PLOT for linear regression output

    Dear STATA-list,

    I'm hoping to get some advice as to how to draw a boxplot, comparing point-estimates and confidence outputs for regression models I'm running.

    Below is an example of my regression code:

    Code:
    regress total_f1_new i.vi_cat_better gender edu_2cat _independent_home htn diabetes smoking alcohol
    i.vi_cat_better ("visual impairment category, in the better eye") is recorded as either none/moderate/severe/blind, and is the independent variable of interest.
    Output has options 1 (moderate), 2(severe) or 3(blind), compared to reference 0(no visual impairment).

    I'm wondering whether it's possible to draw a boxplot with a graph (point estimate, 95% CI) for each of the 3 visual impairment categories, and one for the reference (in this case, the intercept output, with it's 95% CIs)?

    If anyone has any advice, it would be greatly appreciated. Thanks for your consideration.

    William

  • #2
    Dear STATA list;

    I just wanted to try and re-prompt this thread, to see whether I could get any help converting regression output coefficients and 95% CIs, into a box plot?

    Just to clarify: I'm hoping to be able to compare the coefficient/95% CIs of the output for i.vi_cat_better, with the intercept; for the following code:

    Code:
     
     regress total_f1_new i.vi_cat_better gender edu_2cat _independent_home htn diabetes smoking alcohol
    I have tried video tutorials, and PDFs, and the closest I can seem to find is the "predict" command, but it still doesn't seem to do it.

    Would really appreciate any advice, thanks so much for your help.

    William

    Comment


    • #3
      I guess no-one replied because no-one was clear what you were asking. A box plot as conventionally understood is based on median and quartiles. A point estimate and confidence intervals around it is something else again, but with several predictors and an interest in just one, perhaps you seek a margins plot, so

      Code:
      help marginsplot

      Comment


      • #4
        Just to clarify: I'm hoping to be able to compare the coefficient/95% CIs of the output for [...]
        If this is what you wish, the user-written coefplot may be helpful.
        Best regards,

        Marcos

        Comment


        • #5
          Dear Nick and Marcos,

          Thanks very much for replying. Nick, the margins and the marginsplot commands were exactly what I was after.

          I've been watching the stata youtube channel/reading the PDFs, and trying (now) to figure out how to (i) exchange the x/y axes, and/or (ii) create a regression post-estimation forest plot (rather than my post-estimation scatter plot). Do you know whether this is possible?

          Below is my current code, but I can't figure out how to exchange axes, or create a post-estimate forest plot.
          (I have found this previous post, but wasn't able to find an answer here;
          https://www.statalist.org/forums/for...in-stata-graph)

          Thanks, William

          Code:
          regress total_f1_new VI_URE age gender edu_2cat _independent_home diabetes 
          
          
          margins, at(VI_URE=(0(1)2))
          
          
          marginsplot, recast(scatter) ytitle(Mean Factor 1 score (out of 73)) xtitle(VI severity (URE) (0 = normal vision)) title(Average Factor 1 Score by VI Severity (URE))

          Comment


          • #6
            Sorry; I think I figured it out with the HORIZONTAL command. Thanks!

            Comment


            • #7
              create a regression post-estimation forest plot
              Please beware that the terms must convey the correct meaning. Otherwise, it will be hard to understand the message.

              By making reference (twice) to "forest plot", one will give the misleading impression the gist of the message conveys some sort of meta-analysis.

              With regard to the constant, you stated you wish

              to draw a boxplot [...] one for the reference (in this case, the intercept output, with it's 95% CIs)
              If you really wish to have a graph with the constant (plus all coefficients), as already said, coefplot is one of the alternatives.

              What it is provided with the command in #5 represents the predictive margins for VI_URE = 0, 1 and 2.
              Best regards,

              Marcos

              Comment

              Working...
              X